function initPage(baseInfoJson,drugAllergyInfoJson){
	var basePath = $("#basePath").val();
	var allergyDrugTypes = baseInfoJson['allergyDrugTypes'];//过敏药物类型
	
	
	$("select").each(function(){
		$(this).append("<option value=''>---请选择---</option>");
	});
	
	$(".drugAllergyTypeSelect").each(function(){
		var options = "";
		for(var index in allergyDrugTypes){
			var allergyDrugType = allergyDrugTypes[index];
	    	options+="<option value='"+allergyDrugType.uniq_code+"'>"+allergyDrugType.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var drugAllergyRecords = drugAllergyInfoJson['drugAllergyRecords'];//重症监控明细集合
	for(var index in drugAllergyRecords){
		var drugAllergyRecord = drugAllergyRecords[index];
		var add_content= addDrugAllergyRecord();
		add_content.find("input[name$='.drugAllergyName']").val(drugAllergyRecord.drugAllergyName);
		if(drugAllergyRecord.drugAllergyTypeCode){
			var selectOption = add_content.find("select[name$='drugAllergyTypeCode']").find("option[value='"+drugAllergyRecord.drugAllergyTypeCode+"']")
			if(selectOption.length > 0){
				selectOption.attr("selected",true);
			}else{
				$(item).append("<option selected='selected' value='"+drugAllergyRecord.drugAllergyTypeCode+"'>"+drugAllergyRecord.drugAllergyTypeName+"</option>");
			}
			
		};
		add_content.find("input[name$='.drugAllergyTypeName']").val(drugAllergyRecord.drugAllergyTypeName);
		
	} 
	
	
	
	if($("#drugAllergyRecords tbody tr").length <1){
		addDrugAllergyRecord();
	}
}

function addDrugAllergyRecord(){
	var basePath = $("#basePath").val();
	var drugAllergyCountOjb = $("#drugAllergyRecordCount");
	var count = parseInt(drugAllergyCountOjb.val());
	
	var add_content=$("#template_drug_allergy_tr").clone();
	add_content.removeAttr("id");
	
	add_content.find("input[name^='drugAllergyRecords[0].']").each(function(){
		var eventObj = $(this);
		eventObj.attr("name",eventObj.attr("name").replace("drugAllergyRecords[0]", "drugAllergyRecords["+count+"]"));
   		
	});
	
	add_content.find("select[name^='drugAllergyRecords[0].']").each(function(){
		var eventObj = $(this);
		eventObj.attr("name",eventObj.attr("name").replace("drugAllergyRecords[0]", "drugAllergyRecords["+count+"]"));
   		
	});
	
	add_content.find("select[class='drugAllergyTypeSelect']").each(function(){
		$(this).change(function(){
	   		var eventObj = $(this);
	   		var nameObjName = eventObj.attr("name").replace("Code", "Name");
	   		
	   		if(eventObj.val()!=""){
	   			var name=eventObj.find("option:selected").text();
	   			eventObj.next("input[name='"+nameObjName+"']").val(name);
	   		}else{
	   			eventObj.next("input[name='"+nameObjName+"']").val("");
	   		}
	   	});
	});
	
	
	$("#drugAllergyRecords tbody").append(add_content);
	drugAllergyCountOjb.val(count +1);
	return add_content;
}

function deleteDrugAllergyRecord(obj){
	$(obj).parent().parent().remove();
}